#ifndef UDP_H
#define UDP_H

#include <QObject>
#include <QQmlEngine>
#include <QUdpSocket>
#include <QNetworkDatagram>
#include <QDebug>
class Udp : public QObject
{
    Q_OBJECT
    QML_ELEMENT//添加这个需要添加头文件QQmlEngine
public:
    explicit Udp(QObject *parent = nullptr);
    ~Udp();


    Q_INVOKABLE void initSocket();
    Q_INVOKABLE void send();

public slots:
    void readPendingDatagrams();
private:
    QUdpSocket*  udpSocket = nullptr;

signals:
};

#endif // UDP_H
